<template>
  <div class="robot-status">
    <div class="move-status">
      <div>行走状态：</div>
      <div>{{ robotMoveSpeed.MotorAction }}</div>
    </div>
    <div class="handle">
      <div>执行动作：</div>
      <div>
        {{ robotMoveSpeed.RobotActionDesc }}
      </div>
    </div>
    <div class="special">
      <div>专项功能</div>
      <el-tooltip
        class="item"
        effect="dark"
        :content="$t('实时音频分析')"
        placement="bottom"
        :style="isChoosenMode == 0 ? 'cursor:default ' : 'cursor: pointer'"
      >
        <img
          class="cursor-pointer"
          :src="shishiImg"
          alt=""
          @click="audioAnalysisClick"
        />
      </el-tooltip>
    </div>
    <AudioAnalysis
      :analysisDialog="analysisDialog"
      @input="analysisClose"
    ></AudioAnalysis>
  </div>
</template>
<script>
import AudioAnalysis from "./AudioAnalysis.vue";
import {
  API_moveSpeed, //行走速度
} from "@/api/robot/monitor";
export default {
  components: { AudioAnalysis },
  props: ["isChoosenMode"],
  data() {
    return {
      analysisDialog: false, //实时分析弹框dialog
      robotMoveSpeed: {},
      shishiImg: require("@/assets/images/toggle/shishi.png"),
      RobotRunModelTimer: null,
    };
  },
  created() {
    this.getRobotMoveSpeed();
  },
  mounted() {
    this.RobotRunModelTimer = setInterval(() => {
      this.getRobotMoveSpeed(); //获取机器人行走速度
    }, 1000);
  },
  methods: {
    /**实时视频分析btn */
    audioAnalysisClick() {
      this.analysisDialog = true;
    },
    /**弹框关闭 */
    analysisClose() {
      this.analysisDialog = false;
    },
    /**获取机器人行走速度 */
    getRobotMoveSpeed() {
      API_moveSpeed().then((res) => {
        if (res.code == 200 && res.data) {
          this.robotMoveSpeed = JSON.parse(res.data);
        }
      });
    },
  },
  beforeDestroy() {
    clearInterval(this.RobotRunModelTimer);
    this.RobotRunModelTimer = null;
  },
};
</script>
<style lang="scss" scoped>
.robot-status {
  display: flex;
  height: 32px;
  line-height: 32px;
  .move-status,
  .handle {
    display: flex;
    div:nth-child(1) {
      font-size: 12px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #a6acb1;
    }
    div:nth-child(2) {
      font-size: 12px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #ffffff;
    }
  }
  .move-status {
    margin-left: 16px;
  }
  .handle {
    margin-left: 150px;
    div:nth-child(2) {
      min-width: 580px;
    }
  }
  .special {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    color: #ffffff;
    img {
      width: 20px;
      height: 20px;
      margin-left: 27px;
    }
  }
}
</style>
